package com.foruo.code.main;

import com.foruo.code.config.Config;
import com.foruo.code.entity.TableModel;
import com.foruo.code.service.CodeService;
import com.foruo.code.service.DbService;
import com.foruo.code.utils.db.DBManger;
import com.foruo.code.utils.db.DBMangerPool;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;

import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.*;
import java.util.List;

/**
 * 代码自动生成器
 *
 * @author gaoyuan
 */
public class Run {
    /**
     * 主面板
     */
    private JPanel RunMain;
    /**
     * 状态显示
     */
    private JTextArea statusLog;
    /**
     * 用户名
     */
    private JTextField username;
    /**
     * 密码
     */
    private JTextField pwd;
    /**
     * 数据库连接串
     */
    private JTextField dataBaseUrl;
    /**
     * 当前模块
     */
    private JTextField myModel;
    /**
     * 子模块
     */
    private JTextField mySubModel;
    /**
     * 字符过滤
     */
    private JTextField charFilter;
    /**
     * 当前包名
     */
    private JTextField myPackage;
    /**
     * 连接数据库
     */
    private JButton connect;
    /**
     * 数据库树
     */
    private JTree dbTree;
    /**
     * 项目路径
     */
    private JTextField projectPath;
    /**
     * 右键菜单
     */
    private JPopupMenu menu;
    /**
     * 节点路径
     */
    private TreePath[] treePath = null;
    /**
     * 查看模板
     */
    private JButton tempBtn;
    /**
     * 作者
     */
    private JTextField authorNm;
    /**
     * 智能导入权限
     */
    private JButton importBtn;

    /**定义参数 */

    /**
     * 数据库地址
     */
    String dbUrl;
    /**
     * 数据库帐号
     */
    String usernameParam;
    /**
     * 数据库密码
     */
    String pwdParam;
    /**
     * 过滤字符
     */
    String charFilterParam;
    /**
     * 项目路径
     */
    String projectPathParam;
    /**
     * 包名
     */
    String myPackageParam;
    /**
     * 模块
     */
    String myModelParam;
    /**
     * 子模块
     */
    String mySubModelParam;
    /**
     * 作者
     */
    String authorNmParam;

    DbService dbService = new DbService();
    CodeService codeService = new CodeService();

    public Run() {
        //初始组件
        initComponents();
        initBindComponents();
        dbTree.addMouseListener(new MouseAdapter() {
        });
        dbTree.addMouseListener(new MouseAdapter() {
        });

        statusLog.append("操作步骤：\r\n 1、数据数据库配置，点击【连接数据库】，左侧出现数据库表，则表示连接成功；\r\n 2、输入相关信息，选择具体表（按Ctrl可多选,mac下按command），右键选择【生成所有代码】;\r\n \r\n 注：如出现异常现象，请联系【高元】\r\n \r\n");
    }

    /**
     * 初始化组件
     */
    private void initComponents() {
        initValue();
        //正在刷新数据树
//        updateTree();
        //右键菜单
        RightMouse();
    }

    /**
     * 初始化绑定组件
     */
    private void initBindComponents() {
        //连接按钮点击
        connect.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                initValue();
                //正在刷新数据树
                updateTree();
            }
        });
        //查看模板点击事件
        tempBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //弹出模板界面
                JFrame frame = new JFrame("模板管理");
                JPanel rootPanel = new Temp().TempMain;
                frame.setContentPane(rootPanel);
                frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                frame.pack();
                //设置界面大小
                frame.setSize(900, 700);
                frame.setLocationRelativeTo(rootPanel);
                frame.setVisible(true);

            }
        });

        //智能导入点击事件
        importBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //弹出智能导入权限页面
                JFrame frame = new JFrame("智能导入权限管理");
                JPanel rootPanel = new Import().ImportMain;
                frame.setContentPane(rootPanel);
                frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                frame.pack();
                //设置界面大小
                frame.setSize(900, 700);
                frame.setLocationRelativeTo(rootPanel);
                frame.setVisible(true);

            }
        });

        //树点击
        dbTree.addMouseListener(new MouseListener() {
            @Override
            public void mouseClicked(MouseEvent evt) {
                //选择数据库
                if (evt.isMetaDown()) {
                    //右键 没有子节点
                    dbTree = (JTree) evt.getSource();
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) dbTree
                            .getLastSelectedPathComponent();
                    if (node != null && node.getChildCount() == 0) {
                        //最终子节点
                        treePath = dbTree.getSelectionPaths();
                        //创建右键菜单
                        menu.show(dbTree, evt.getX(), evt.getY());
                    }
                }
            }

            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }
        });
    }

    /**
     * 初始化变量
     */
    public void initValue() {
        //获取数据库链接串
        dbUrl = dataBaseUrl.getText();
        //获取数据库帐号
        usernameParam = username.getText();
        //获取数据库密码
        pwdParam = pwd.getText();
        //获取过滤字符
        charFilterParam = charFilter.getText();
        Config.charfilters = charFilterParam.split(",");
        //获取包名
        myPackageParam = myPackage.getText();
        //获取模块
        myModelParam = myModel.getText();
        //获取子模块
        mySubModelParam = mySubModel.getText();
        //获取项目路径
        projectPathParam = projectPath.getText();
        //获取作者
        authorNmParam = authorNm.getText();

    }

    /**
     * 更新数据库树
     */
    public void updateTree() {
        DefaultMutableTreeNode root = new DefaultMutableTreeNode("数据库列表");
        DefaultTreeModel treeMode = new DefaultTreeModel(root);
        DBManger dBManger = new DBManger(dbUrl, usernameParam, pwdParam);
        DBMangerPool dBMangerPool = DBMangerPool.getInstance();
        dBMangerPool.setDbMangerPools(Config.dbKey, dBManger);
        List<String> dbs = dbService.getDatabase(Config.dbKey);
        for (int j = 0; j < dbs.size(); j++) {
            DefaultMutableTreeNode leftnode1 = new DefaultMutableTreeNode(
                    dbs.get(j));
            root.add(leftnode1);
            List<TableModel> tables = dbService.getTables(Config.dbKey, dbs
                    .get(j));
            for (int k = 0; k < tables.size(); k++) {
                DefaultMutableTreeNode leftnode2 = new DefaultMutableTreeNode(
                        tables.get(k).getTableName() + "(" + tables.get(k).getTableDesc() + ")");
                leftnode1.add(leftnode2);
            }
        }
        dbTree.setModel(treeMode);
        statusLog.append("数据库列表刷新成功\r\n");
    }

    /**
     * 创建右键菜单
     */
    public void RightMouse() {
        JMenuItem mCode;
        menu = new JPopupMenu();
        mCode = new JMenuItem("生成所有代码-ssm(jsp)");
        menu.add(mCode);
        //生成实体
        mCode.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                initValue();
                if (myModelParam == null || "".equals(myModelParam)) {
                    statusLog.append("警告：没有填写要生成的模块\r\n");
                } else if (projectPathParam == null || "".equals(projectPathParam)) {
                    statusLog.append("警告：没有填写项目路径\r\n");
                } else if (authorNmParam == null || "".equals(authorNmParam)) {
                    statusLog.append("警告：没有填写作者\r\n");
                } else {
                    if (mySubModelParam == null || "".equals(mySubModelParam)) {
                        mySubModelParam = null;
                    }
                    String msg = codeService.auotoCode(Config.templatePath, treePath, myPackageParam, myModelParam, mySubModelParam, projectPathParam, authorNmParam);
                    if (msg != null) {
                        statusLog.append(msg + "\r\n");
                    }
                }
            }
        });

        mCode = new JMenuItem("生成所有代码-ssm(springboot)");
        menu.add(mCode);
        //生成实体
        mCode.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                initValue();
                if (myModelParam == null || "".equals(myModelParam)) {
                    statusLog.append("警告：没有填写要生成的模块\r\n");
                } else if (projectPathParam == null || "".equals(projectPathParam)) {
                    statusLog.append("警告：没有填写项目路径\r\n");
                } else if (authorNmParam == null || "".equals(authorNmParam)) {
                    statusLog.append("警告：没有填写作者\r\n");
                } else {
                    if (mySubModelParam == null || "".equals(mySubModelParam)) {
                        mySubModelParam = null;
                    }
                    String msg = codeService.auotoCode(Config.templateSpringBootPath, treePath, myPackageParam, myModelParam, mySubModelParam, projectPathParam, authorNmParam);
                    if (msg != null) {
                        statusLog.append(msg + "\r\n");
                    }
                }
            }
        });

        mCode = new JMenuItem("生成所有代码-VUE管理端");
        menu.add(mCode);
        mCode.addActionListener((e) -> {
            initValue();
            if (myModelParam == null || "".equals(myModelParam)) {
                statusLog.append("警告：没有填写要生成的模块\r\n");
            } else if (projectPathParam == null || "".equals(projectPathParam)) {
                statusLog.append("警告：没有填写项目路径\r\n");
            } else if (authorNmParam == null || "".equals(authorNmParam)) {
                statusLog.append("警告：没有填写作者\r\n");
            } else {
                if (mySubModelParam == null || "".equals(mySubModelParam)) {
                    mySubModelParam = null;
                }
                String msg = codeService.auotoCode(Config.TEMPLATE_VUE_MANAGEPATH, treePath, myPackageParam, myModelParam, mySubModelParam, projectPathParam, authorNmParam);
                if (msg != null) {
                    statusLog.append(msg + "\r\n");
                }
            }
        });


//        mCode = new JMenuItem("生成测试代码");
//        menu.add(mCode);
//        //生成实体
//        mCode.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                initValue();
//                if (myModelParam == null || "".equals(myModelParam)) {
//                    statusLog.append("警告：没有填写要生成的模块\r\n");
//                } else if (projectPathParam == null || "".equals(projectPathParam)) {
//                    statusLog.append("警告：没有填写项目路径\r\n");
//                } else if (authorNmParam == null || "".equals(authorNmParam)) {
//                    statusLog.append("警告：没有填写作者\r\n");
//                } else {
//                    if (mySubModelParam == null || "".equals(mySubModelParam)) {
//                        mySubModelParam = null;
//                    }
//                    String msg = codeService.auotoCodeTest(treePath, myPackageParam, myModelParam, mySubModelParam, projectPathParam,authorNmParam);
//                    if (msg != null) {
//                        statusLog.append(msg + "\r\n");
//                    }
//                    statusLog.append("警告：其实不是警告\r\n");
//                }
//            }
//        });


        mCode = new JMenuItem("生成数据库结构说明书");
        menu.add(mCode);
        mCode.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                initValue();
                if (projectPathParam == null || "".equals(projectPathParam)) {
                    statusLog.append("警告：没有填写项目路径\r\n");
                } else {
                    String msg = codeService.autoCreateDoc(treePath, projectPathParam);
                    if (msg != null) {
                        statusLog.append(msg + "\r\n");
                    } else {
                        statusLog.append("警告：其实不是警告\r\n");
                    }
                }
            }
        });
    }

    /**
     * 方法入口
     *
     * @param args
     */
    public static void main(String[] args) {
        JFrame frame = new JFrame("Raising 代码生成器（Mysql版）");
        JPanel rootPanel = new Run().RunMain;
        frame.setContentPane(rootPanel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        //设置界面大小
        frame.setSize(900, 700);
        frame.setLocationRelativeTo(rootPanel);
        frame.setVisible(true);

        new Run();


    }

    private void createUIComponents() {
        // TODO: place custom component creation code here
    }

    {
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
        $$$setupUI$$$();
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        RunMain = new JPanel();
        RunMain.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1));
        RunMain.setToolTipText("");
        final JPanel panel1 = new JPanel();
        panel1.setLayout(new GridLayoutManager(1, 7, new Insets(0, 0, 0, 0), -1, -1));
        RunMain.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false));
        panel1.setBorder(BorderFactory.createTitledBorder("数据库设置"));
        final JLabel label1 = new JLabel();
        label1.setText("数据库地址：");
        panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        dataBaseUrl = new JTextField();
        dataBaseUrl.setText("localhost:3306");
        panel1.add(dataBaseUrl, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
        final JLabel label2 = new JLabel();
        label2.setText("数据库账号：");
        panel1.add(label2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        username = new JTextField();
        username.setText("root");
        panel1.add(username, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
        final JLabel label3 = new JLabel();
        label3.setText("数据库密码：");
        panel1.add(label3, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        pwd = new JTextField();
        pwd.setText("root");
        panel1.add(pwd, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
        connect = new JButton();
        connect.setText("连接数据库");
        panel1.add(connect, new GridConstraints(0, 6, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final JPanel panel2 = new JPanel();
        panel2.setLayout(new GridLayoutManager(2, 8, new Insets(0, 0, 0, 0), -1, -1));
        RunMain.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false));
        panel2.setBorder(BorderFactory.createTitledBorder("参数配置"));
        final JLabel label4 = new JLabel();
        label4.setText("过滤字符：");
        panel2.add(label4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        charFilter = new JTextField();
        charFilter.setText("sys,cms,plug");
        panel2.add(charFilter, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
        final JLabel label5 = new JLabel();
        label5.setText("包名：");
        panel2.add(label5, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final JLabel label6 = new JLabel();
        label6.setText("子模块：");
        panel2.add(label6, new GridConstraints(1, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        myPackage = new JTextField();
        myPackage.setText("com.raising.modules");
        panel2.add(myPackage, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
        mySubModel = new JTextField();
        mySubModel.setText("");
        panel2.add(mySubModel, new GridConstraints(1, 6, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
        final JLabel label7 = new JLabel();
        label7.setText("模块：");
        panel2.add(label7, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        myModel = new JTextField();
        panel2.add(myModel, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
        final JLabel label8 = new JLabel();
        label8.setText("项目路径：");
        panel2.add(label8, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        projectPath = new JTextField();
        projectPath.setText("/Users/gy/Downloads/out");
        panel2.add(projectPath, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
        final JLabel label9 = new JLabel();
        label9.setText("作者：");
        panel2.add(label9, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        authorNm = new JTextField();
        panel2.add(authorNm, new GridConstraints(0, 6, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
        final JPanel panel3 = new JPanel();
        panel3.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
        RunMain.add(panel3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        panel3.setBorder(BorderFactory.createTitledBorder("数据库列表"));
        final JScrollPane scrollPane1 = new JScrollPane();
        scrollPane1.setEnabled(false);
        panel3.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
        dbTree = new JTree();
        scrollPane1.setViewportView(dbTree);
        final JScrollPane scrollPane2 = new JScrollPane();
        scrollPane2.setEnabled(false);
        panel3.add(scrollPane2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
        statusLog = new JTextArea();
        statusLog.setEnabled(false);
        scrollPane2.setViewportView(statusLog);
        final JPanel panel4 = new JPanel();
        panel4.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
        RunMain.add(panel4, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false));
        panel4.setBorder(BorderFactory.createTitledBorder("操作"));
        tempBtn = new JButton();
        tempBtn.setEnabled(true);
        tempBtn.setHorizontalAlignment(0);
        tempBtn.setText("查看模板");
        panel4.add(tempBtn, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        importBtn = new JButton();
        importBtn.setText("智能导入权限");
        panel4.add(importBtn, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final JPanel panel5 = new JPanel();
        panel5.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
        RunMain.add(panel5, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    }

    /**
     * @noinspection ALL
     */
    public JComponent $$$getRootComponent$$$() {
        return RunMain;
    }
}